package com.woniuxy.yoga.admin.web.controller;


import com.woniuxy.yoga.admin.dao.mapper.RoleResourceMapper;
import com.woniuxy.yoga.admin.dao.model.RoleResource;
import com.woniuxy.yoga.admin.service.RoleResourceService;
import com.woniuxy.yoga.commons.core.model.Result;
import com.woniuxy.yoga.commons.web.log.YogaLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 角色资源关联表 前端控制器
 * </p>
 *
 * @author 韦用文,刘存益,郎腾霄
 * @since 2023年11月28日
 */
@RestController
@RequestMapping("/roleResource")
@Api(tags = "角色资源关联相关接口")
public class RoleResourceController {
    @Autowired
    private RoleResourceService roleResourceService;

    /**
     * 根据角色ID查资源权限
     * @param roleId
     * @return
     */
    @GetMapping("/selectResourceByRole/{roleId}")
    @ApiOperation("根据角色ID查资源权限")
    @YogaLog("根据角色Id查资源权限")
    public Result<List<RoleResource>> selectResourceByRole(@PathVariable("roleId") Integer roleId){
        List<RoleResource> roleResources = roleResourceService.selectResourceByRole(roleId);
        return Result.getListResult(RoleResource.class).setData(roleResources).setMessage("查询资源权限成功");
    }
}

